import { defineConfig, loadEnv } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import AutoImport from 'unplugin-auto-import/vite'
import Unocss from 'unocss/vite'

// https://vitejs.dev/config/
export default defineConfig((config) => {
	const root = process.cwd()
	const env = loadEnv(config.mode, root)
	
	// config.mode === 'development'
	// console.log('root', root)
	// console.log('env', env)
	// console.log('config', config)
	return {
		plugins: [
			uni(),
			Unocss(),
			AutoImport({
				imports: ["vue", "uni-app", "pinia"],
				dts: true,
			})
		],
		server: {
			port: '8900',
			proxy: {
				'/apifilter/ApiRoute.ashx': {
					target: 'https://nx5.abc5g.com/',
					changeOrigin: true, // 是否改变域名
					secure: false,
				},
				'^/ApiFilter/UploadFiles.ashx': {
					target: 'https://nx5.abc5g.com/',
					changeOrigin: true, // 是否改变域名
					secure: false
				},
			}
		}
	}
})